<template>
    <div class="forgetPassword">
        <van-nav-bar
      title="找回密码"
      left-text="返回"
      :fixed="true"
      left-arrow
      @click-left="back"
    ></van-nav-bar>
    <van-field v-model="phone" label="手机号" />
    <van-field v-model="newPassword" type="password" label="新密码" />
    <van-button class="btn" round type="primary" size="large" @click="determine"
      >确定</van-button>
    </div>
</template>

<script>
    export default {
        name:'ForgetPassword',
        data(){
            return{
                phone:'',
                newPassword:''
            }
        },
        methods:{
            back(){
                this.$router.go(-1)
            },
            determine(){
                this.axios({
                    method:'post',
                    url:'/retrievePassword',
                    data:{
                        phone:this.phone,
                        password:this.newPassword
                    }
                }).then(result=>{

                    this.$notify({ type: "danger", message: result.data.msg });
                    if(result.data.code == 'L001'){
                        this.$notify({ type: "success", message: result.data.msg +'，3秒后自动跳转到登录页面' });
                        setTimeout(()=>{
                            this.$router.go(-1)
                        },3000)
                    }
                })
            }
        }
    }
</script>

<style lang="less" scoped>
.forgetPassword{
    padding-top: 76px;
  .van-nav-bar--fixed{
    padding-top: 30px;
    background-color: #0022ab;
  }
  /deep/.van-nav-bar__title{
    color: #fff;
  }
    .btn{
        width: 90%;
        margin: 0 5%;
        margin-top: 10px;
    }
}
</style>